package com.hivekion.system.controller;

import com.hivekion.common.annotation.AutoLog;
import com.hivekion.common.entity.PagedResultVo;
import com.hivekion.common.entity.SelectOption;
import com.hivekion.common.enums.OperationTypeEnum;
import com.hivekion.system.domain.vo.*;
import com.hivekion.system.service.ISysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/dictData")
public class SysDictDataController {

      @Autowired
      ISysDictDataService dataService;

      @PostMapping("/add")
      @PreAuthorize("@Permission.hasPermi('pro:sys:dic:add')")
      @AutoLog(
	      value = "添加字典数据",
	      level = 1,
	      operationType = OperationTypeEnum.INSERT,
	      module = "系统管理/字典管理")
      public boolean add(@RequestBody SysDictDataCreateVo vo) {
	    return dataService.add(vo);
      }

      @PutMapping("/edit")
      @PreAuthorize("@Permission.hasPermi('pro:sys:dic:edit')")
      @AutoLog(
	      value = "编辑字典数据",
	      level = 1,
	      operationType = OperationTypeEnum.UPDATE,
	      module = "系统管理/字典管理")
      public boolean edit(@RequestBody SysDictDataUpdateVo vo) {
	    return dataService.edit(vo);
      }

      @DeleteMapping("/remove")
      @PreAuthorize("@Permission.hasPermi('pro:sys:dic:remove')")
      @AutoLog(
	      value = "删除字典数据",
	      level = 9,
	      operationType = OperationTypeEnum.DELETE,
	      module = "系统管理/字典管理")
      public boolean remove(String key) {
	    return dataService.remove(key);
      }

      @GetMapping("/get")
      public SysDictDataModelVo get(String key) {
	    return dataService.get(key);
      }

      @GetMapping("/getList")
      public PagedResultVo<SysDictDataViewVo> getList(SysDictDataSearchPageInputVo inputVo) {
	    return dataService.getList(inputVo);
      }

      @GetMapping("/getOptions")
      public List<SelectOption> getOptions(String dicType) {
	    return dataService.getOptions(dicType);
      }
}
